<--- %%NOBANNER%% --> _addoptn.sas
 BackForward
/*-------------------<-- Start of Description -->--------------------\
| To add permanent format library to sasauto library;                |
|--------------------<--- End of Description -->---------------------|
|--------------------------------------------------------------------|
|--------------<--- Start of Files or Arguments Needed -->-----------|
| Arguments Required:                                                |
|    op    - sasauto library;                                        |
|    addn  - the library you want to add;                            |
|    at    - you want to put the added library in front of sasauto,  |
|            or after sasauto, so that SAS will search the added     |
|            library first;                                          |
|---------------<--- End of Files or Arguments Needed -->------------|
|--------------------------------------------------------------------|
|----------------<--- Start of Example and Usage -->-----------------|
| Example:                                                           |
|    option %_addoptn( sasautos, mymacs )                            |
|           %_addoptn( fmtsearch, oldbits, at=end ) ;                |
| Usage: %_addoptn( op, addn, at=front );                            |
\-------------------<--- End of Example and Usage -->---------------*/
%macro _addoptn( op, addn, at=front );
/*--------------------------------------------\
| Author:   Duo Zhou;                         |
| Created:  4-19-2002 5:12pm;                 |
| Purpose:  add library to SASAUTO;           |
\--------------------------------------------*/
%local mainpart rebuild ;
%if (%index(%quote(%upcase(&addn)), %quote(\)) or %index(%quote(%upcase(&addn)), %quote(/))) %then %do;
   libname _addn "%sysfunc(dequote(&addn))"; %let addn=_addn; 
%end;
%let mainpart = %sysfunc( compress( %sysfunc( getoption( &op ) ), () )) ;
%if &at= front %then %let rebuild = &addn &mainpart ;
%else %let rebuild = &mainpart &addn ;
option &op = ( &rebuild ); 
%mend  _addoptn;